package authattempt

import "context"

// Service 用户登录失败次数记录
type Service interface {
	//Add adds add new auth attempt record for provided username
	Add(ctx context.Context, username, ipAddress string) error
	// Validate checks if username has to many auth attempts inside a window.
	// Will return true if provided username do not have too many attempts.
	Validate(ctx context.Context, username string) (bool, error)
	// Reset resets all auth attempts attached to username
	Reset(ctx context.Context, username string) error
}

type LoginAttempt struct {
	Id        int64
	Username  string
	IpAddress string
	Created   int64
}

func (l *LoginAttempt) TableName() string {
	return "sys_login_attempt"
}
